# Copyright (C) 2006 Brian Davis

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

"""
This is the reference backend for the Branches SCM abstraction library
"""

import os
import errors

    
## Preamble ##

# Before being loaded, we will check to see if the path we're working on hosts
# a branch of the same type is the one this client loosely wraps. 

# Because this is the base and includes no functionality, we'll just raise an 
# exception. 

#cwd = os.getcwd()

# This is where SCM-specific checks would live.

#raise errors.ModuleNotFoundError("base", "Base", cwd)


## Class Definition ##

class base:
    __scm_client__ = "base"
    __scm_name__ = "Base"
    
    def add(item):
        """
        Add a file to the current working copy. If I{item} is a directory, recursively add its contents.

        @type item: string
        @param item: The name of the file or directory to add. 
        @return: An Result object.
        """
        return "add(%s) called." % (item,)

    def remove(item):
        """
        Remove a file from the current working copy. If I{item} is a directory, recursively remove its contents.

        @type item: string
        @param item: The name of the file or directory to remove. 
        @return: An Result object.
        """
        return "remove(%s) called." % (item,)

    def checkout(branch, revision = None):
        """
        Check out code from I{branch}. If I{revision} is not given, check out the latest revision.

        @type branch: string
        @type revision: string
        @param branch: The branch name or location.
        @param revision: The revision number.
        @return: An Result object.
        """
        return "checkout(%s, %s) called." % (branch, revision)

    def update(branch, revision = None):
        """
        Sync the working copy with I{branch}. If I{branch} is not given, sync to the parent repository. If I{revision} is not given, sync with the latest revision.

        @type branch: string
        @type revision: string
        @param branch: The branch name or location.
        @param revision: The revision number.
        @return: An Result object.
        """
        return "update(%s, %s) called." % (branch, revision)

    def commit(item):
        """
        Commit the current changes in the working copy to the parent repository. If I{item} is given, commit only changes to I{item}. 

        @type item: string
        @param item: The name of the file or directory to commit. 
        @return: An Result object.
        """
        return "commit(%s) called." % (item,)
